#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
typedef pair<int, int> pii;

void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    int mx = 0;
    vector<pii> p(n);
    map<int, int> mp;
    for(int i =  0; i < n; i++){
        cin >> a[i];
        p[i] = {a[i], i};
        mp[a[i]]++;
        mx = max(mx, mp[a[i]]);
    }
    sort(p.begin(), p.end());
    if(mx > n / 2) {
        cout << 0 << endl;
        return;
    }
    for(int i = 0; i < n; i++){
        a[p[i].second] = p[(i + mx) % n].first;
    }
    for(auto x : a) {
        cout << x << ' ';
    }
    cout << endl;

}

int main() {
    int t;
    cin >> t;
    while(t--) solve();
    return 0;
}